package com.shiguiwu.springmybatis.designpattern.strategy;

import com.shiguiwu.springmybatis.designpattern.strategy.event.MJCouponDiscount;
import com.shiguiwu.springmybatis.designpattern.strategy.event.NYGCouponDiscount;
import com.shiguiwu.springmybatis.designpattern.strategy.service.CouponDiscountService;
import lombok.extern.slf4j.Slf4j;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * @description: 策略模式
 *
 * 模拟优惠券类型
 * 直减券
 *
 * 满减券
 *
 * 折扣券
 *
 * n元购
 * @author: stone
 * @date: Created by 2021/9/9 16:16
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.designpattern.strategy
 */
@Slf4j
public class StrategyTests {

    public static void main(String[] args) {
        CouponDiscountService service = new CouponDiscountService();
        double amount = service.discountAmount(0, 3, 4, 4);

        log.info("实付金额是==============> {}", amount);

        Context<Double> context = new Context<>(new NYGCouponDiscount());
        BigDecimal skuPrice = new BigDecimal("7.0");
        context.discountAmount(2.0, skuPrice);

        Context<Map<String, String>> context1 = new Context<>(new MJCouponDiscount());
        Map<String, String> map = new HashMap<>(2);
        map.put("x", "5.0");
        map.put("n", "1.0");
        context1.discountAmount(map, skuPrice);


    }
}
